<?php

namespace App\Transformers\Frontend;

use App\Models\FileTransaction;
use League\Fractal\TransformerAbstract;

class FileTransformer extends TransformerAbstract
{

    protected $availableIncludes = ['config'];

    protected $hidden = ['author_id', 'created_at', 'updated_at', 'config_id'];

    public function transform(FileTransaction $model)
    {
        $model->makeHidden($this->hidden);
        return $model->attributesToArray();
    }

    public function includeConfig(FileTransaction $model)
    {
        $config = $model->config;
        if (!$config) {
            return $this->null();
        }
        return $this->item($config, new ConfigTransformer());
    }
}